//
//  MRMCommodityTableCell.m
//  MeiRiMoney
//
//  Created by qiuqk on 13-6-29.
//  Copyright (c) 2013年 MeiRiCai. All rights reserved.
//

#import "MRMCommodityTableCell.h"
#import "MRMAlipayWithdrawViewController.h"
#import "MRMMobileRechargeViewController.h"

@implementation MRMCommodityTableCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)exchangeClick:(id)sender
{
	// 判断是否有足够积分兑换
	int integralBalance = [MRMSdk getIntegralBalance];
	if (integralBalance < self.commodity.Integral)
	{
		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"啊哦！您的积分不足，赶紧去做任务吧，很快就能兑换了" delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles: nil];
		[alertView show];
		return;
	}
	UIViewController *viewController = nil;
	if (self.commodity.Category == 1)
	{
		MRMMobileRechargeViewController *mobileView = [[MRMMobileRechargeViewController alloc] initWithNibName:@"MRMMobileRechargeViewController" bundle:nil];
		mobileView.commodity = self.commodity;
		viewController = mobileView;
		viewController.title = @"手机充值";
	}
	else if (self.commodity.Category == 2)
	{
		MRMAlipayWithdrawViewController *alipayView = [[MRMAlipayWithdrawViewController alloc] initWithNibName:@"MRMAlipayWithdrawViewController" bundle:nil];
		alipayView.commodity = self.commodity;
		viewController = alipayView;
		viewController.title = @"提现到支付宝";
	}
	
	[self.navigationController pushViewController:viewController animated:YES];
}
@end
